package com.tangyuan.video.controller;

import com.baomidou.mybatisplus.annotation.TableField;
import com.tangyuan.common.result.Result;
import com.tangyuan.dto.VideoPublishDto;
import com.tangyuan.video.service.VideoPublishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.math.BigDecimal;
import java.math.BigInteger;

@RestController
@RequestMapping("/video")
public class VideoPublishController {

    @Autowired
    VideoPublishService videoPublishService;


    //发布小视频选择音乐
    @GetMapping("/publish/getMusicList")
    public Result getMusicList(Integer pageNumber,Integer pageSize){
        return videoPublishService.getMusicList(pageNumber,pageSize);
    }

    //发布小视频接口
    @PostMapping("/publish/littleVideo")
    public Result publishLittleVideo(@RequestParam MultipartFile image,
                                     @RequestParam MultipartFile video,
                                     @RequestParam String title,
                                     @RequestParam String place,
                                     @RequestParam Integer tag,
                                     @RequestHeader("Authorization") String token) {
      return videoPublishService.publishLittleVideo(image,video,title,place,tag,token);
    }

    //发布音乐接口
    @PostMapping("/publish/littleMusic")
    public Result publishLittleVideo(
                                     @RequestParam MultipartFile music,
                                     @RequestParam MultipartFile image,
                                     @RequestParam String title,
                                     @RequestParam String singer,
                                     @RequestHeader("Authorization") String token) {
        return videoPublishService.publishLittleMusic(music,image,singer,title,token);
    }

    //发布音乐接口
    @GetMapping("/publish/insertMusic")
    public Result insertMusic(
            @RequestParam String folderPath,
            @RequestHeader("Authorization") String token) {
        return videoPublishService.insertMusic(token,folderPath);
    }

    @PostMapping("/publish/littleVideon")
    public Result publishLittleVideo( @RequestParam(name = "video",required = false) MultipartFile video,
                                      @RequestParam(name = "categoryId",required = false) Integer categoryId,
                                      @RequestParam String title,
                                       @RequestParam String address,
                                       @RequestParam BigDecimal longitude,
                                       @RequestParam BigDecimal latitude,
                                       @RequestHeader("Authorization") String token,
                                       @RequestParam(name = "littleVideoUrl",required = false) String littleVideoUrl) {
        return videoPublishService.publishLittleVideo(video,title,address,longitude,latitude,token,littleVideoUrl,categoryId);
    }

}
